package com.zuofei.springcloud.controller;

import com.zuofei.springcloud.constant.Topic;
import com.zuofei.springcloud.producer.KafKaCustomrProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class SendMsgController {
    @Autowired
    private KafKaCustomrProducer producer;
    @Autowired
    private KafkaTemplate kafkaTemplate;

    /***
     * 发送消息体为基本类型的消息
     */
    @GetMapping("sendSimple")
    public void sendSimple() {
        for(int i = 0 ;  i < 10000;i++) {
            producer.sendMessage(Topic.SIMPLE, "hello spring boot kafka"+i);
        }
    }
}
